package com.youhome.service.service.impl;

import com.youhome.common.exception.CustomException;
import com.youhome.common.response.Result;
import com.youhome.common.response.ResultCode;
import com.youhome.service.mapper.BTemplateSMSMapper;
import com.youhome.service.model.BTemplateSMS;
import com.youhome.service.service.BTemplateSMSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * Created by chen365 on 2017/12/15.
 */
@Service
public class BTemplateSMSServiceImpl implements BTemplateSMSService {
    @Autowired
    private BTemplateSMSMapper bTemplateSMSMapper;

    @Override
    public List<BTemplateSMS> selectAll(Integer type) throws CustomException {

        BTemplateSMS templateSMS = new BTemplateSMS();
        if (StringUtils.isEmpty(type)) {
            throw  new CustomException(ResultCode.EMPTY_TEMPLATE_TYPE);
        }
        templateSMS.setType(type);
        templateSMS.setStatus(true);

        return bTemplateSMSMapper.selectAll(templateSMS);
    }
}
